using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace FPISystem.Control
{
    public partial class BruceButton : UserControl
    {

        private int border = 10;


        public int Border
        {
            get { return border; }
            set { border = value; }
        }

        private int iniHeight;

        private int iniWidth;

        private int iniTop;

        private int iniLeft;

        private bool changed;

        private bool mousedown;

        public BruceButton()
        {
            InitializeComponent();
            iniHeight = Height;
            iniWidth = Width;
            iniTop = Top;
            iniLeft = Left;
            changed = false;
            mousedown = false;
        }

        private void BruceButton_Load(object sender, EventArgs e)
        {
            iniHeight = Height;
            iniWidth = Width;
            iniTop = Top;
            iniLeft = Left;
            changed = false;
            mousedown = false;
            this.Cursor = Cursors.Hand;
        }

        private void BruceButton_MouseMove(object sender, MouseEventArgs e)
        {

            EnLarge();
        }

        private void BruceButton_MouseLeave(object sender, EventArgs e)
        {
            mousedown = false;
            Reback();
        }

        private void BruceButton_MouseDown(object sender, MouseEventArgs e)
        {
            mousedown = true;
            Reback();
        }

        private void EnLarge()
        {
            if (!changed && !mousedown)
            {
                Height = iniHeight + 2 * border;
                Width = iniWidth + 2 * border;
                Top = iniTop - border;
                Left = iniLeft - border; 
                changed = true;
            }
        }

        private void Reback()
        {
            if (changed)
            {
                Height = iniHeight;
                Width = iniWidth;
                Top = iniTop;
                Left = iniLeft;
                changed = false;
            }
        }

        private void BruceButton_MouseUp(object sender, MouseEventArgs e)
        {
            mousedown = false;
            //EnLarge();
        }
    }
}
